﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Nacos.AspNetCore.V2;
using System.Collections.Generic;
using NetMicro.Core.ConfigureOptions;
using NetMicro.Nacos.Abstractions;

namespace NetMicro.Nacos
{


    public static class ServiceCollectionExtensions
    {
        /// <summary>
        /// 添加服务发现与注册
        /// </summary>
        /// <param name="services"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static IServiceCollection AddServiceDiscovery(this IServiceCollection services, IConfiguration configuration)
        {
            services.AddConfigure<List<LocalServiceOptions>>();
            services.AddSingleton<IServiceClient, ServiceClient>();
            services.AddNacosAspNet(configuration, "nacos");
            return services;
        }
    }
}